<include file="Common:layout" />
<body style="background-color: rgb(255, 255, 255); overflow: auto; cursor: default;">
<div class="page">
    <div class="fixed-bar">
        <div class="item-title">
            <div class="subject">
                <h3>后台导航管理</h3>
                <h5>网站后台导航添加与管理</h5>
            </div>
        </div>
    </div>
    <div id="explanation" class="explanation">
        <div id="checkZoom" class="title"><i class="fa fa-lightbulb-o"></i>
            <h4 title="提示相关设置操作时应注意的要点">操作提示 - 最多两级导航</h4>
            <span title="收起提示" id="explanationZoom"></span>
        </div>
    </div>
    <form method="post">
        <input type="hidden" value="ok" name="form_submit">
        <div class="flexigrid">
            <div class="hDiv">
                <div class="hDivBox">
                    <table cellspacing="0" cellpadding="0">
                        <thead>
                        <tr>
                            <th align="center" style="padding-left:40px;"><div style="text-align: center; width: 80px;">操作</div></th>
                            <th align="center"><div style="text-align: center; width: 50px;">ID</div></th>
                            <th align="center"><div style="text-align: center; width: 150px;">导航名称</div></th>
                            <th align="center"><div style="text-align: center; width: 60px;">开启</div></th>
                            <th align="center"><div style="text-align: center; width: 60px;">排序</div></th>
                            <th align="center"><div style="text-align: center; width: 50px;">图标</div></th>
                            <th align="center"><div style="text-align: center; width: 150px;">控制器</div></th>
                            <th align="center"><div style="text-align: center; width: 150px;">方法</div></th>
                            <th align="center"><div style="text-align: center; width: 80px;">商家开启</div></th>
                            <th axis="col10"><div></div></th>
                        </tr>
                        </thead>
                    </table>
                </div>
            </div>
            <div class="tDiv">
                <div class="tDiv2">
                    <a href="{:U('Navigation/add_nav')}">
                        <div class="fbutton">
                            <div title="新增分类" class="add">
                                <span><i class="fa fa-plus"></i>新增导航</span>
                            </div>
                        </div>
                    </a>
                </div>
                <div style="clear:both"></div>
            </div>
            <div style="height: auto;" class="bDiv">
                <table cellspacing="0" cellpadding="0" border="0" id="article_cat_table" class="flex-table autoht">
                    <tbody id="treet1">
                    <foreach name="navlist" item="nav">
                        <tr>
                            <td>
                                <div style="text-align:left;min-width:80px!important; max-width:inherit !important;">
                                    <a href="javascript:;" onclick="delNav({$nav['nav_id']});" class="btn red"><i class="fa fa-trash-o"></i>删除</a>
                                </div>
                            </td>
                            <td class="sort">
                                <div style="text-align: center; width: 50px;">{$nav.nav_id}</div>
                            </td>
                            <td class="name">
                                <div style="text-align: center; width: 150px;">
                                    <input type="text" value="{$nav.nav_name}" onchange="changeTableVal('navigation','nav_id','{$nav.nav_id}','nav_name',this)" style="text-align: left; width:130px;"/>
                                </div>
                            </td>
                            <td align="center" class="">
                                <div style="text-align: center; width: 60px;">
                                    <if condition='$nav[nav_status] eq 1'>
                                        <span class="yes" onClick="changeTableVal('navigation','nav_id','{$nav.nav_id}','nav_status',this)"><i class="fa fa-check-circle"></i>是</span>
                                        <else />
                                        <span class="no" onClick="changeTableVal('navigation','nav_id','{$nav.nav_id}','nav_status',this)"><i class="fa fa-ban"></i>否</span>
                                    </if>
                                </div>
                            </td>
                            <td align="center" class="">
                                <div style="text-align: center; width: 60px;">
                                    <input type="text" value="{$nav.nav_sort}" onchange="changeTableVal('navigation','nav_id','{$nav.nav_id}','nav_sort',this)" style="text-align: center; width:50px;" data-type="number"/>
                                </div>
                            </td>
                            <td align="center" class="">
                                <div style="text-align: center; width: 50px;">
                                    <input type="text" value="{$nav.nav_ico}" onchange="changeTableVal('navigation','nav_id','{$nav.nav_id}','nav_ico',this)" style="text-align: center; width:40px;" data-type="number"/>
                                </div>
                            </td>
                            <td align="center" class="">
                                <div style="text-align: center; width: 150px;">
                                    <input type="text" value="{$nav.nav_c}" onchange="changeTableVal('navigation','nav_id','{$nav.nav_id}','nav_c',this)" style="text-align: center; width:130px;"/>
                                </div>
                            </td>
                            <td align="center" class="">
                                <div style="text-align: center; width:150px;">
                                    <input type="text" value="{$nav.nav_a}" onchange="changeTableVal('navigation','nav_id','{$nav.nav_id}','nav_a',this)" style="text-align: center; width:130px;"/>
                                </div>
                            </td>
                            <td align="center" class="">
                                <div style="text-align: center; width: 60px;">
                                    <if condition='$nav[state] eq 1'>
                                        <span class="yes" onClick="changeTableVal('navigation','nav_id','{$nav.nav_id}','state',this)"><i class="fa fa-check-circle"></i>是</span>
                                        <else />
                                        <span class="no" onClick="changeTableVal('navigation','nav_id','{$nav.nav_id}','state',this)"><i class="fa fa-ban"></i>否</span>
                                    </if>
                                </div>
                            </td>

                            <td style="width: 100%;">
                                <div>&nbsp;</div>
                            </td>
                        </tr>

                        <if condition="$nav['son_navs'] neq null">
                            <foreach name="nav['son_navs']" item="sub">
                                <tr style="background: #fffceb;">
                                    <td style="padding-left:40px;">
                                        <div style="text-align:left;min-width:80px!important; max-width:inherit !important;">
                                            <a href="javascript:;" onclick="delNav({$sub['nav_id']});" class="btn red"><i class="fa fa-trash-o"></i>删除</a>
                                        </div>
                                    </td>
                                    <td class="sort">
                                        <div style="text-align: center; width: 50px;">{$sub.nav_id}</div>
                                    </td>
                                    <td class="name">
                                        <div style="text-align: center; width: 150px;">
                                            <input type="text" value="{$sub.nav_name}" onchange="changeTableVal('navigation','nav_id','{$sub.nav_id}','nav_name',this)" style="text-align: left; width:130px;"/>
                                        </div>
                                    </td>
                                    <td align="center" class="">
                                        <div style="text-align: center; width: 60px;">
                                            <if condition='$sub[nav_status] eq 1'>
                                                <span class="yes" onClick="changeTableVal('navigation','nav_id','{$sub.nav_id}','nav_status',this)"><i class="fa fa-check-circle"></i>是</span>
                                                <else />
                                                <span class="no" onClick="changeTableVal('navigation','nav_id','{$sub.nav_id}','nav_status',this)"><i class="fa fa-ban"></i>否</span>
                                            </if>
                                        </div>
                                    </td>
                                    <td align="center" class="">
                                        <div style="text-align: center; width: 60px;">
                                            <input type="text" value="{$sub.nav_sort}" onchange="changeTableVal('navigation','nav_id','{$sub.nav_id}','nav_sort',this)" style="text-align: center; width:50px;" data-type="number"/>
                                        </div>
                                    </td>
                                    <td align="center" class="">
                                        <div style="text-align: center; width: 50px;">
                                            <input type="text" value="{$sub.nav_ico}" onchange="changeTableVal('navigation','nav_id','{$sub.nav_id}','nav_ico',this)" style="text-align: center; width:40px;" data-type="number"/>
                                        </div>
                                    </td>
                                    <td align="center" class="">
                                        <div style="text-align: center; width: 150px;">
                                            <input type="text" value="{$sub.nav_c}" onchange="changeTableVal('navigation','nav_id','{$sub.nav_id}','nav_c',this)" style="text-align: center; width:130px;"/>
                                        </div>
                                    </td>
                                    <td align="center" class="">
                                        <div style="text-align: center; width:150px;">
                                            <input type="text" value="{$sub.nav_a}" onchange="changeTableVal('navigation','nav_id','{$sub.nav_id}','nav_a',this)" style="text-align: center; width:130px;"/>
                                        </div>
                                    </td>
                                    <td align="center" class="">
                                        <div style="text-align: center; width: 60px;">
                                            <if condition='$sub[state] eq 1'>
                                                <span class="yes" onClick="changeTableVal('navigation','nav_id','{$sub.nav_id}','state',this)"><i class="fa fa-check-circle"></i>是</span>
                                                <else />
                                                <span class="no" onClick="changeTableVal('navigation','nav_id','{$sub.nav_id}','state',this)"><i class="fa fa-ban"></i>否</span>
                                            </if>
                                        </div>
                                    </td>
                                    <td style="width: 100%;">
                                        <div>&nbsp;</div>
                                    </td>
                                </tr>
                            </foreach>
                        </if>
                    </foreach>
                    </tbody>
                </table>
                <br/>
            </div>
        </div>
    </form>
</div>
<script>
    // 删除导航
    function delNav( id )
    {
        layer.confirm('您确认删除此导航吗？', {
            btn: ['确认','取消']
        }, function(){
            $.ajax({
                url: "{:U('Navigation/del_nav')}",
                type: "post",
                data: {nav_id: id},
                dataType:'JSON',
                beforeSend: function () {
                    layer.msg('删除中..', {icon: 16,time:500});
                },
                success: function (msg)
                {
                    if(msg.status == 'success'){
                        location.reload(true);
                    }else{
                        layer.alert(msg.msg);
                    }
                }
            });
        });
    }

    // 点击展开 收缩节点
    function treeClicked(obj,cat_id)
    {
        var src = $(obj).attr('src');
        if(src == '__PUBLIC__/images/tv-expandable.gif')
        {
            $(".parent_id_"+cat_id).show();
            $(obj).attr('src','__PUBLIC__/images/tv-collapsable-last.gif');
        }else{
            $(".parent_id_"+cat_id).hide().find('img').attr('src','__PUBLIC__/images/tv-expandable.gif');
            $(obj).attr('src','__PUBLIC__/images/tv-expandable.gif');
        }
    }
</script>
</body>
</html>